{template 'header'}
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="site_name" class="layui-form-label">
                <span class="x-red">*</span>站点名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="site_name" name="site_name" required="" lay-verify="site_name"
                       autocomplete="off" value="{$setting['site_name']}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>必须
            </div>
        </div>
        <div class="layui-form-item">
            <label for="site_kefu1" class="layui-form-label">
                <span class="x-red">*</span>QQ客服1
            </label>
            <div class="layui-input-inline">
                <input type="text" id="site_kefu1" name="site_kefu1" required="" lay-verify="site_kefu1"
                       autocomplete="off" value="{$setting['site_kefu1']}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>必须
            </div>
        </div>
        <div class="layui-form-item">
            <label for="site_kefu2" class="layui-form-label">
                <span class="x-red"></span>QQ客服2
            </label>
            <div class="layui-input-inline">
                <input type="text" id="site_kefu2" name="site_kefu2" required="" lay-verify="site_kefu2"
                       autocomplete="off" value="{$setting['site_kefu2']}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="site_kefu3" class="layui-form-label">
                <span class="x-red"></span>QQ客服3
            </label>
            <div class="layui-input-inline">
                <input type="text" id="site_kefu3" name="site_kefu3" required="" lay-verify="site_kefu3"
                       autocomplete="off" value="{$setting['site_kefu3']}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="save" lay-submit="site">
                保存
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //自定义验证规则
        form.verify({
            site_name: function (value) {
                if (value.length < 3) {
                    return '站点名称至少得3个字符';
                }
            }
            , site_kefu1: [/^[0-9]*$/, 'QQ应为全数字']
            , site_kefu2: [/^[0-9]*$/, 'QQ应为全数字']
            , site_kefu3: [/^[0-9]*$/, 'QQ应为全数字']
        });

        //监听提交
        form.on('submit(save)', function (data) {
            console.log(data);
            var form_data = data.field
            //发异步，把数据提交给php
            var url = '{php echo $this->createWebUrl("setting",array("op"=>"site"))}'
            $.post(url, form_data, function (ret) {
                console.log(ret)
                if (ret.code) {
                    layer.msg(ret.msg, {icon: 1});
                } else {
                    layer.msg(ret.msg, {icon: 0});
                }
            }, 'json')
            return false;
        });


    });
</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>